/*******************************************************************************
 * Copyright (c) 2014 Francesco Gabbrielli (http://www.francescogabbrielli.it).
 * 
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the GNU Public License v2.0
 * which accompanies this distribution, and is available at
 * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
 * 
 * Contributors:
 *     Francesco Gabbrielli - initial API and implementation
 ******************************************************************************/
package it.francescogabbrielli.android.solidalapp;

import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;

@Entity
public class Response extends Message {
	
	/** Message type value when accepting a request */
	public final static String TYPE_ACCEPT = "accept";
	/** Message type value when sending feedback */
	public final static String TYPE_FEEDBACK = "feedback";

		
	@Id
	@GeneratedValue(strategy = GenerationType.IDENTITY)
	protected Long id;
	
	/** Id of the request whose this is the response */
	private long requestId;	
	
	/** Feedback for the response, positive or negative */
	private int feedback;
	
	public Response() {}
	
	public Response(long id) {
		super(id);
		this.id = id;
	}
	
	@Override
	public Long getId() {
		return id;
	}
	
	public long getRequestId() {
		return requestId ;
	}
	
	public void setRequestId(long requestId) {
		this.requestId = requestId;
	}
	
	public int getFeedback() {
		return feedback;
	}
	
	public void setFeedback(int feedback) {
		this.feedback = feedback;
	}
	
	public String toString() {
		return "RESPONSE "  
				+ (getId()!=null ? getId() : "<new>")
				+ ": REQUEST " + requestId;
	};
	
}
